public class Demo {
    public static void main(String[] args) {
        // 测试单例模式
        Singleton singleton = Singleton.getInstance();
        singleton.doSomething();

        // 测试工厂模式
        Factory factory = new Factory();
        Product productA = factory.createProduct("A");
        productA.operation();

        // 测试命令模式
        Receiver receiver = new Receiver();
        Command command = new ConcreteCommand(receiver);
        Invoker invoker = new Invoker();
        invoker.setCommand(command);
        invoker.executeCommand();

        // 测试装饰者模式
        Component component = new ConcreteComponent();
        Component decorated = new ConcreteDecorator(component);
        decorated.operation();
    }
} 